﻿using StudyCompanion.Commons.Result;
using StudyCompanion.Core.Repository;

namespace StudyCompanion.Core.Services
{
    /// <summary>
    /// 
    /// </summary>
    public class BaseService<TEntity> : IAppService where TEntity : class, new()
    {
        protected readonly BaseRepository<TEntity> _repository;
        public BaseService(BaseRepository<TEntity> repository)
        {
            _repository = repository;
        }

        protected static CommonResult Problem(string msg, int code = 400)
            => new(code, msg);

        protected static CommonResult Success()
            => new();

        protected static CommonResult<T> Success<T>(T data)
            => new(data);
    }

    /// <summary>
    /// 
    /// </summary>
    public class BaseService : IAppService
    {
        protected static CommonResult Problem(string msg, int code = 400)
            => new(code, msg);

        protected static CommonResult Success()
            => new();

        protected static CommonResult<T> Success<T>(T data)
            => new(data);
    }
}
